<?xml version="1.0"?>
<!-- prettier-ignore -->
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link
      rel="stylesheet"
      type="text/css"
      href="chrome://__addonRef__/content/lib/css/github-markdown.css"
    />
    <link
      rel="stylesheet"
      href="chrome://__addonRef__/content/lib/css/katex.min.css"
      crossorigin="anonymous"
    />
    <script>
      // Add message to print window
      window.onmessage = async function (e) {
        if (e.data.type === "print") {
          // Serialize the HTMLDocument as an XHTML string
          var parser = new DOMParser();
          var serializer = new XMLSerializer();
          var htmlString = e.data.html;
          const styleString = e.data.style;
          const style = document.createElement("style");
          style.innerHTML = styleString;
          document.head.appendChild(style);
          var htmlDoc = parser.parseFromString(htmlString, "text/html");
          var xhtmlString = serializer.serializeToString(htmlDoc);
          document.querySelector(".markdown-body").innerHTML = xhtmlString;
        }
      };
    </script>
    <style>
      @page {
        margin: 25mm 20mm 25mm 20mm;
        size: A4;
      }
      @media print {
        body {
          height: auto;
          margin: 0;
          -webkit-print-color-adjust: exact;
          color-adjust: exact;
        }

        @page: footer {
          display: none;
        }
        @page: header {
          display: none;
        }
      }
      .markdown-body {
        box-sizing: border-box;
        min-width: 200px;
        max-width: 980px;
        margin: 0 auto;
        padding: 0px;
      }

      td,
      th {
        word-break: break-all;
      }

      @media (max-width: 767px) {
        .markdown-body {
          padding: 15px;
        }
      }
    </style>
  </head>
  <body>
    <article class="markdown-body">
      <h1>Print to PDF</h1>
      <p>Waiting for data...</p>
    </article>
  </body>
</html>
